<%@page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
<script type="text/javascript">
    /**
     * 自定义验证规则
     */
    function validateForm(){
        form.bootstrapValidator({
            message: "无效的值",
            feedbackIcons: {
                valid: "glyphicon glyphicon-ok",
                invalid: "glyphicon glyphicon-remove",
                validating: "glyphicon glyphicon-refresh"
            },
            fields: {
                sendMsgContent: {
                    validators: {
                        notEmpty: {message: "回复消息不可为空"}
                    }
                }
            }
        });
    }

    /**
     * 粉丝文本消息回复
     */
	<shiro:hasPermission name="back_gotofansTextInfoPage_reply">
    function replyMessage(){
        var selectedRow = $("#tt").bootstrapTable('getSelections');
        if (selectedRow.length == 1) {
        	$("#wxName").val(selectedRow[0].wxName);
            $("#btn_reply").attr("data-target", "#replyMessageModal");/**选中了记录后才可打开对应的模态框**/
            $.ajax({
                type: "POST",
                url: "${basePath}/back/wx/fansMessage/text/getTextMessageInfoObject.sjson",
                data: {textMessageInfoId:selectedRow[0].textMessageInfoId},
                dataType: "JSON",
                success: function(result){
                    var data = JSON.parse(result.data);
                    $("#sendMsgContent").val("");
                    $("#htextMessageInfoId").val(data.wxTextMessageInfo.textMessageInfoId);
                    $("#hfromUserName").val(data.wxTextMessageInfo.fromUserName);
                    $("#hcontent").empty().html(data.wxTextMessageInfo.content);
                }
            });
        }else {
            $("#btn_reply").attr("data-target", "");/**没有选中记录后不可打开对应的模态框**/
            showMsg("请选择一行记录！");
        }
	}
	</shiro:hasPermission>
</script>
<div class="modal fade" id="replyMessageModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" >
	<div class="modal-dialog" style="width:70%">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h5 class="modal-title" id="myModalLabel">回复粉丝文本消息</h5>
			</div>
			<div class="modal-body">
				<form id="form1" method="post" action="${basePath}/back/wx/fansMessage/text/saveReplyTextMessage.sjson">
					<input id="hfromUserName" type="hidden" name="fromUserName" value="" />
					<input id="wxName" type="hidden" name="wxName" value="" />
					<input id="htextMessageInfoId" type="hidden" name="textMessageInfoId" value=""  noclear="true"/>
					<table align="center" class="addOrEditTable table table-bordered" style="width:100%;">
						<tr>
							<td class="toright_td" width="150px">消息:&nbsp;&nbsp;</td>
							<td class="toleft_td"><span id="hcontent"></span></td>
						</tr>
						<tr>
							<td class="toright_td" width="150px"><span style="color:red">* </span>回复消息:&nbsp;&nbsp;</td>
							<td class="toleft_td">
								<div class="form-group">
									<textarea id="sendMsgContent" class="form-control input-sm" type="text" name="sendMsgContent" placeholder="请输入回复消息"></textarea>
								</div>
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" id="validateBtn" class="btn btn-primary" onclick="submitForm()">保存</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>